using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class tbTinhTrangBUS
    {
        public static void Insert(tbTinhTrang tinhtrang)
        {
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            ttDAL.Insert(tinhtrang);
        }
        public static void Update(tbTinhTrang tinhtrang)
        {
            tbTinhTrangDAL ttDAl = new tbTinhTrangDAL();
            ttDAl.Update(tinhtrang);
        }
        public static void Delete(int iD)
        {
            tbTinhTrangDAL ttDAl = new tbTinhTrangDAL();
            ttDAl.Delete(iD);
        }
        public static tbTinhTrangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            return ttDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTinhTrangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            return ttDAL.Get(cri.Criter, 0, 0, tbTinhTrangColumns.MaTT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbTinhTrang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTinhTrangColumns.MaTT.ToString(), Condition.EQUAL, iD);
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            tbTinhTrangCollection ttCollection = ttDAL.Get(cri.Criter, 0, 0, tbTinhTrangColumns.MaTT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ttCollection.Count > 0)
                return ttCollection[0];
            return null;
        }
        public static tbTinhTrangCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            return ttDAL.Get(cri.Criter, 1, number, tbTinhTrangColumns.MaTT.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTinhTrangCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangDAL ttDAL = new tbTinhTrangDAL();
            return ttDAL.Get(cri.Criter, 1, number, tbTinhTrangColumns.MaTT.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}